package com.xhdx.pattern.composite;
/**
 * 测试
 *
 */
public class CompositeTest {
    public static void main(String[] args) {
       Folder aFolder = new Folder("A夹",0, "2020-05-10");

       Folder aaFolder = new Folder("AA夹",1, "2020-05-11");
       Folder abFolder = new Folder("AB夹",1, "2020-05-11");

       Folder abaFolder = new Folder("ABA夹",2, "2020-05-14");
       Folder abbFolder = new Folder("ABB夹",2, "2020-05-14");
       Folder aaaFolder = new Folder("AAA夹",2, "2020-05-14");
       Folder aabFolder = new Folder("AAB夹",2, "2020-05-14");

       aFolder.add(aaFolder);
       aFolder.add(abFolder);

       aaFolder.add(aaaFolder);
       aaFolder.add(aabFolder);

       abFolder.add(abaFolder);
       abFolder.add(abbFolder);

       //打印所有文件夹
       System.out.println(aFolder); 
       for (Folder downFolder : aFolder.getFolderList()) {
          System.out.println("|--"+downFolder);
          for (Folder folder : downFolder.getFolderList()) {
             System.out.println("|----"+folder);
          }
       }        
    }
 }